package com.jinglin.web;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jinglin.component.RedisComponent;
import com.jinglin.entity.constants.Constants;
import com.jinglin.entity.dto.SysSettingDto;
import com.jinglin.entity.dto.TokenUserInfoDto;
import com.jinglin.entity.enums.VideoStatusEnum;
import com.jinglin.entity.po.VideoInfo;
import com.jinglin.entity.po.VideoInfoPost;
import com.jinglin.mapper.VideoInfoFilePostMapper;
import com.jinglin.redis.RedisData;
import com.jinglin.service.VideoInfoPostService;
import com.jinglin.service.VideoInfoService;
import com.jinglin.service.impl.VideoInfoServiceImpl;
import com.jinglin.utils.FFmpegUtils;

import com.jinglin.utils.ProcessUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

import java.io.PrintStream;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@SpringBootTest
public class test {
    @Autowired
    private VideoInfoServiceImpl videoInfoServiceImpl;
    @Autowired
    private RedisTemplate redisTemplate;
    @Test
    public void buildCache(){
        // 启动前统一建立一下缓存。
        List<String> ids = videoInfoServiceImpl.list().stream().map(VideoInfo::getVideoId).collect(Collectors.toList());

        for (String id : ids) {
            // 一一建立缓存
            videoInfoServiceImpl.buildVideoInfoCache(id);
        }

/*        final String CMD_GET_CODE = "ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"%s\"";
        String cmd = String.format(CMD_GET_CODE, "C:\\Users\\PC\\Videos\\2ddac69f075a69da4b429de873b1579f.mp4");
        String result = ProcessUtils.executeCommand(cmd, true);
        System.out.println(result);*/
    }

}

